package com.aiti.lulian.config;

import com.alibaba.nacos.api.config.annotation.NacosValue;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

/**
 * @ClassName SmsConfig
 * @Description
 * @Author diaozhende
 * @Date 2024/6/22 0022 8:26
 */
@Component
public class SmsConfig {


    @Value("${aliyun.sms.endpoint}")
    private String endpoint;

    @Value("${aliyun.sms.accessKeyId}")
    private String accessKeyId;

    @Value("${aliyun.sms.accessKeySecret}")
    private String accessKeySecret;

    public String getEndpoint() {
        return endpoint;
    }

    public void setEndpoint(String endpoint) {
        this.endpoint = endpoint;
    }

    /**
     * 短信客户端Client
     */
    @Bean
    public com.aliyun.dysmsapi20170525.Client smsClient() throws Exception {
        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
//                .setAccessKeyId(accessKeyId)
//                .setAccessKeySecret(accessKeySecret);
                .setAccessKeyId("LTAI5tFkhysJFJVHuBAZHi4q")
                .setAccessKeySecret("pl0aiVlpp1kEOhGTSjE8G0wrH91fXS");
        //访问的域名, Endpoint 请参考 https://api.aliyun.com/product/Dysmsapi
//        config.endpoint = "dysmsapi.aliyuncs.com";
        config.endpoint = endpoint;
        return new com.aliyun.dysmsapi20170525.Client(config);

    }
}
